﻿@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <link rel="shortcut icon" href="favicon.ico">
    <link rel="icon" type="image/gif" href="~/img/animated_favicon1.gif">
    <link href="~/UILibs/easyui/themes/default/easyui.css" rel="stylesheet" />
    <link href="~/UILibs/easyui/themes/icon.css" rel="stylesheet" />
    <link href="~/Css/css.css" rel="stylesheet" />

    <script src="~/Scripts/jquery-1.7.1.min.js"></script>
    <script src="~/Scripts/jquery.jqprint-0.3.js"></script>
    <script src="~/UILibs/easyui/jquery.easyui.min.js"></script>

    <script src="~/UILibs/easyui/locale/easyui-lang-zh_CN.js"></script>
    <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
    <script src="~/Scripts/jquery.validate.min.js"></script>
    <script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script>
    <script src="~/Scripts/datagrid-detailview.js"></script>
    <title></title>
    <style type="text/css">
        .subtotal {
            font-weight: bold;
            color: black;
            /*//background-color: dodgerblue;*/
            height: 200px;
            width: 200px;
            font-size: 20px;
        }

        .subtotal2 {
            font-weight: bold;
            color: black;
            width: 6%;
            margin-top: 10px;
            background-color: orange;
            font-size: 20px;
        }
        /*合计单元格样式*/
    </style>
    <script type="text/javascript">
        $(function () {
            ////动态加载  店铺列表
            //$("#shopName").combobox({
            //    url: pageConfig.getShopName,
            //    //action 
            //    valueField: "shopID",
            //    textField: "shopName"
            //});
            //页面加载显示总金额    等同于下面  查询加载总金额
            $.ajax({
                url: " /PancakeOrderStatic/GetOrderAll?adminUsername=" + $("#txtShopInfo").val() + '&date1=' + $('#txtDate1').val() + '&date2=' + $('#txtDate2').val() + '&userPhone=' + $('#txtphone').val() + '&storeid=' + $("#shopName").combobox('getValue'),
                dataType: "JSON",
                type: "GET",
                success: function (data) {
                    $("#txtOrderSum").val(data.OrderSum);
                    
                    $("#txtDisMoney").val(data.Discountmoney + "元");
                    //pageConfig.Discountmoney = data.Discountmoney + "元";
                    $("#txtActuMoney").val(data.Actualmoney + "元");
                    //pageConfig.Actualmoney = data.Actualmoney + "元";
                    // $("#txtShouldMoney").val((data.Discountmoney + data.Actualmoney) + "元");
                    $("#txtShouldMoney").val((data.Shouldmoney) + "元");
                    // pageConfig.Shouldmoney = (data.Discountmoney + data.Actualmoney) + "元";
                }
            });
        });
    </script>

    <script type="text/javascript">
        $(function () {


            $('#shopName').combobox({
                valueField: "StoreID", //Value字段 
                textField: "StoreName", //Text字段                 
                url: "/PresellWares/GetStore", //数据源 
            });

            $("#data").datagrid({
                fit: true,
                title: '预定煎饼订单统计分析',
                striped: true,
                rownumbers: true,
                showFooter: true,
                columns:
                    [[
                            { field: 'orderCode', title: '订单编号', width: 160, halign: 'center', align: 'center' },
                            { field: 'userCode', title: '客户编号', width: 160, halign: 'center', align: 'center' },
                            { field: 'wechatName', title: '微信名称', width: 160, halign: 'center', align: 'center' },
                            { field: 'userPhone', title: '手机号码', width: 150, halign: 'center', align: 'center' },
                            { field: 'orderTime', title: '订单日期', width: 180, halign: 'center', sortable: true, align: 'center' },
                            { field: 'pindentTakeTime', title: '取餐日期', width: 180, halign: 'center', sortable: true, align: 'center' },
                            { field: 'isRepeat', title: '是否复购', width: 100, halign: 'center', align: 'center' },
                            { field: 'orderSumprice', title: '订单金额(RMB/元)', width: 100, halign: 'center', align: 'center' },
                            { field: 'preferentialMoney', title: '优惠金额(RMB/元)', width: 100, halign: 'center', align: 'center' },
                            { field: 'storeName', title: '消费店铺', width: 150, halign: 'center', align: 'center' }, 
                            { field: 'pindentStatus', title: '订单状态', width: 200, halign: 'center', align: 'center' }, 
                    ]],
                singleSelect: true,
                loadMsg: '正在加载数据,请耐心等待.......',
                url: pageConfig.getAction,
                queryParams: {
                    adminUsername: $("#txtShopInfo").val().trim(),
                    userPhone: $("#txtphone").val().trim(),
                    date1: $('#txtDate1').val(),
                    date2: $('#txtDate2').val(),
                    storeid: $("#shopName").combobox('getValue'),
                },
                pagination: true,
                pageSize: 25,
                pageList: [25, 30, 35],
                sortName: 'pindentTakeTime',
                sortOrder: 'asc',
                toolbar: '#tool',

            });
            $('#data').datagrid({
                view: detailview,
                detailFormatter: function (index, row) {
                    return '<div style="padding:12px"><table class="ddv"></table></div>';
                },
                onExpandRow: function (index, row) {
                    var ddv = $(this).datagrid('getRowDetail', index).find('table.ddv');
                    ddv.datagrid({
                        url: '/PancakeOrderStatic/GetDetailByID',
                        fitColumns: true,
                        singleSelect: true,
                        rownumbers: true,
                        loadMsg: '',
                        height: 'auto',
                        columns: [[
                             { field: 'waresCode', title: '商品编号', width: 100, halign: 'center', align: 'center' },
                             { field: 'waresName', title: '商品名称', width: 100, halign: 'center', align: 'center' },
                             { field: 'waresNumber', title: '购买数量', width: 100, halign: 'center', align: 'center' },
                             { field: 'standard', title: '商品规格', width: 100, halign: 'center', align: 'center' },
                             { field: 'waresPrice', title: '单价', width: 100, halign: 'center', align: 'center' },
                             { field: 'TotalPrice', title: '总价', width: 100, halign: 'center', align: 'center' }
                        ]],
                        onResize: function () {
                            $('#data').datagrid('fixDetailRowHeight', index);
                        },
                        queryParams: {
                            orderCode: row.orderCode,
                        }
                    });
                    $('#data').datagrid('fixDetailRowHeight', index);
                }
            });
        });
        var pageConfig = {
            getAction: '@Url.Action("GetOrderByEf")',
            getActionAll: '@Url.Action("GetOrderAll")',
            getShopName: '@Url.Action("GetShopName")',
            Shouldmoney: "",
            Discountmoney: "",
            Actualmoney: "",
        };

        function searchData() {
            $.ajax({
                //查询加载总金额
                // Shouldmoney Discountmoney Actualmoney //txtShouldMoney  txtDisMoney txtActuMoney
                url: " /PancakeOrderStatic/GetOrderAll?adminUsername=" + $("#txtShopInfo").val() + '&date1=' + $('#txtDate1').val() + '&date2=' + $('#txtDate2').val() + '&userPhone=' + $('#txtphone').val() + '&storeid=' + $("#shopName").combobox('getValue'),
                dataType: "JSON",
                type: "GET",
                success: function (data) {
                 
                    $("#txtDisMoney").val(data.Discountmoney + "元");
                    pageConfig.Discountmoney = data.Discountmoney + "元";
                    $("#txtActuMoney").val(data.Actualmoney + "元");
                    pageConfig.Actualmoney = data.Actualmoney + "元";
                    $("#txtShouldMoney").val(data.Shouldmoney + "元");
                    $("#txtOrderSum").val(data.OrderSum);
                

                }
            });
            //alert($("#shopName").combobox('getValue')); //获取到的是  id getText 应该是 获取到的name
            var start = $("#txtDate1").datebox('getValue');
            var end = $("#txtDate2").datebox('getValue');
            if (txtDate1.value > txtDate2.value) {
                alert("开始日期不能大于结束日期！");
                $("#txtDate1").textbox('setValue');//清空文本框的值
                $("#txtDate1").textbox('clear');
                $("#txtDate2").textbox('setValue');
                $("#txtDate2").textbox('clear');
                txtDate1.focus();
                txtDate2.focus();
                return false;
            }
            $("#data").datagrid('load', {
                adminUsername: $("#txtShopInfo").val().trim(),
                userPhone: $("#txtphone").val(),
                date1: $('#txtDate1').val(),
                date2: $('#txtDate2').val(),
                storeid: $("#shopName").combobox('getValue'),
            });

        }
    </script>
</head>
<body class="easyui-layout" style="width: 100%; height: 100%">
    <div data-options="region:'center'" id="dataPrint">

        <table id="data" style="height: 50px"></table>
        <table id="data1" hidden="hidden" style="height: 50px"></table>
    </div>

    <div id="tool" style="padding: 30px;">
        <form id="formid" method='post' action='/OrderStatistic/Excel'>
        </form>
        <div>
            微信名称：
                    <input id="txtShopInfo" type="text" onchange="searchData()" />
            &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp 
                 客户手机号：
                    <input id="txtphone" type="text" onchange="searchData()" />
            &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp 
                 店铺名称：
                 <input id="shopName" class="easyui-combobox" name="shopName" />
            &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp 
               日期：<input id="txtDate1" type="text" class="easyui-datebox" />
            -- 
                <input id="txtDate2" type="text" class="easyui-datebox" onchange="searchData()" />
            &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp 
                <a class="easyui-linkbutton" iconcls="icon-search" onclick="searchData()">查询</a>

            <div style="margin-top: 20px;">
                <span style="font-size: larger; color: red">&nbsp&nbsp &nbsp&nbsp&nbsp   &nbsp&nbsp&nbsp &nbsp&nbsp&nbsp   注意:默认显示为今天的订单成交量,点击"+"号查看订单详细内容</span>
                <br />
                 &nbsp&nbsp&nbsp  &nbsp&nbsp&nbsp  &nbsp&nbsp&nbsp  &nbsp&nbsp&nbsp<span class="subtotal" style="">总应收金额为：</span>
                <input id="txtShouldMoney" type="text" class="subtotal2" />
                &nbsp&nbsp&nbsp<span class="subtotal">总优惠金额为：</span>
                <input id="txtDisMoney" type="text" class="subtotal2" />
                &nbsp&nbsp&nbsp<span class="subtotal">总实际收入为：</span>
                <input id="txtActuMoney" type="text" class="subtotal2" />
                &nbsp&nbsp&nbsp<span class="subtotal">交易成功量为：</span>
                <input id="txtOrderSum" type="text" class="subtotal2" />
           
            </div>

        </div>

    </div>
    <style>
        #dataPrint.datagrid-btable tr {
            height: 50px;
        }
    </style>


</body>

</html>
